home *** CD-ROM | disk | FTP | other *** search
- {$D-,L-,Y-,R+}
-
- UNIT TwoWayLB;
-
- { **********************************************************************
- *
- * Unit : TwoWayLb
- *
- * Author : Ian Hayes
- * Soft Systems Ltd,
- * London,UK
- * Compuserve id: 100010,1415
- *
- * Description :
- *
- * A new listbox type that returns the list of items
- * in the dialog listbox into the transfer buffer
- * PStrCollection.
- *
- * Ordinary listboxes only return the listbox
- * selection (or multiple selections) as integers.
- * Those integers are then related to the transfer
- * buffer PStrCollection setup as part of the
- * pre dialog transfer buffer mechanism.
- *
- * This new listbox derivative returns the
- * full listbox item list by disposing the original
- * transfer buffer PStrCollection and replacing it with
- * the strings found in the listbox.
- *
- ********************************************************************* }
-
- { :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
-
- INTERFACE
-
- uses
-
- {$IFDEF Ver70}
- Objects,
- OWindows,
- ODialogs,
- {$ELSE}
- WObjects,
- {$ENDIF}
- WinTypes,
- WinProcs,
- Strings;
-
- { :::::::::::::::::::::::::::::::::::::::::::::::::::::: }
-
- TYPE
-
- PTwoWayListBox = ^TTwoWayListBox;
-
- TTwoWayListBox = OBJECT(TListBox)
- FUNCTION Transfer(DataPtr: POINTER;
- TransferFlag: WORD): WORD; VIRTUAL;
- END;
-
-
- { ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
-
- IMPLEMENTATION
-
- { ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
-
- FUNCTION TTwoWayListBox.Transfer(DataPtr: POINTER;
- TransferFlag: WORD): WORD;
- VAR
- TotNo,Idx: INTEGER;
- W : WORD;
- AStr : ARRAY[0..200] OF CHAR;
- AStrColl : PStrCollection;
-
- { +++++++++++++++++++++++++++ }
-
- PROCEDURE ZapStr(AStr: PChar); FAR;
- BEGIN
- StrDispose(AStr);
- END;
-
- { +++++++++++++++++++++++++++ }
-
- BEGIN
- IF TransferFlag <> tf_GetData THEN
- W := TListBox.Transfer(DataPtr,TransferFlag)
- ELSE
- BEGIN
- AStrColl := PStrCollection(DataPtr^);
- AStrColl^.ForEach(@ZapStr);
- AStrColl^.DeleteAll;
- TotNo := GetCount;
- FOR Idx := 0 TO (TotNo-1) DO
- BEGIN
- GetString(AStr,Idx);
- AStrColl^.AtInsert(Idx,StrNew(AStr));
- END;
- IF (GetWindowLong(HWindow,gwl_Style) AND lbs_MultipleSel) <> 0 THEN
- W := 8
- ELSE
- W := 6;
- END;
- Transfer := W;
- END;
-
-
- { :::::::::::::::::::::::::::::::::::::::::::::::::::::: }
-
- BEGIN
-
- END.